package com.mt.mtyx.home.controller;

import com.mt.mtyx.common.auth.AuthContextHolder;
import com.mt.mtyx.common.result.Result;
import com.mt.mtyx.home.service.HomeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 首页相关接口
 *
 * @author WMT
 * @Date 2023/9/21 17:03
 */
@Api(tags = "首页")
@RequestMapping("/api/home")
@RestController
public class HomeController {

    @Autowired
    private HomeService homeService;

    @ApiOperation("首页数据显示接口")
    @GetMapping("/index")
    public Result<Map<String, Object>> index(HttpServletRequest request) {
        Long userId = AuthContextHolder.getUserId();
        return Result.success(homeService.getHomeData(userId));
    }
}
